The present invention relates generally to object-oriented diagrams, and more particularly to generating computer programs for queries formed by manipulating the object-oriented diagrams.
Object-oriented diagrams are often used to describe data structures within a database. The data structures are typically the target of various operations, such as database queries and updates, as well as object-oriented language operations. These operations are implemented by using a query. A query is a set of commands that specify a condition and retrieve information from the database that matches the condition set by the query. A query is specified by a query language which enables the retrieval and display of data from the database. Typical relational query languages are used to perform complicated searches that match conditions such as equal to, not equal to, greater than, greater than or equal to, less than, less than or equal to, range equal, and range not equal.
Another type of operation that is frequently implemented by a query language is a join which is a database table operation that creates a resultant entry in another table (temporary) for each entry in one table whose key field matches that of an entry in the other. An inner join and an outer join are two types join operators. The inner join when applied to two existing relations (tables), produces a third table that consists of all possible ordered joinings of records from the first table with records from the second for which certain specified criteria on the data values from the two tables are met. An outer join performs an extended join operation in which the rows in one relational table than have no counterpart in the second relational table appear in the resulting relation table with all null values.
Presently, there are several types of query languages in use. One of the most commonly used query languages for implementing database operations is a structured query language (SQL), which expresses the query as a sequence of statements. The process of expressing the query in SQL is tedious and error prone. In particular, SQL requires typing hundreds of lines of complicated commands that typically take a very long time to type and usually are accompanied with errors. Another type of query is an object-oriented language programming interface, which is described in Premerlani et al., "An Object-Oriented Relational Database," Communications of the ACM (November 1990), Vol. 33, No. 11, pp. 99-109. Although the object-oriented language programming interface provides a better interface than SQL, the programmer must still type the query, which is subject to syntactic and semantic errors. Language sensitive editors can provide some relief from certain types of errors, but the keyboard is still a bottle neck as with SQL. Still another type of query language is a query by example (QBE), which is a fill in the blanks approach to questioning a database. The QBE approach also requires a lot of typing and does not provide an object-oriented expression of the query. Another type of query language is a natural language interface, which allows a user to question a database in free-form English. In order to translate the user's English question into a request for information from the database, natural language interfaces contain a specialized vocabulary and rules for putting together queries using the vocabulary. The natural language interface also requires a lot of typing and does not provide an object-oriented expression of the query.
Queries formulated from graphical interfaces have been used to overcome the drawbacks associated with the above-approaches, which use a keyboard to formulate the query. An example of a graphical interface used to formulate a query is disclosed in Czejdo et al., "A Graphical Data Manipulation Language for an Extended Entity-Relationship Model," Computer, March 1990, pp. 26-36. Czejdo et al. interactively queries a database via operations on an object diagram, but is unable to automatically generate computer code that can be integrated into another program to execute the query operations. Although the graphical interface described in Czejdo et al. may be sufficient to formulate a query for an application developer, it is very difficult for an application user to formulate a query in view of the many problems associated with expressing a query. Thus, there is a need to automatically generate the computer code from the object-oriented diagram.